Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add gd and gD to go to declaration and type definition #250

Merged
merged 1 commit into from
Jan 20, 2020

Conversation

alisonatwork
Copy link
Collaborator

This PR adds support for the gd and gD commands in a way that I think makes sense in the context of VS Code.

In vim, gd seems to search up through the current code block to where it thinks the current identifier (variable/function) might have been defined. With this change, amVim will have the same effect, although it will also jump into a different file if the identifier you are on is defined elsewhere. This is the same action that happens in VS Code when you Ctrl-Click.

In vim, gD seems to search down from line 0 to where it thinks the current identifier (variable/function) might have been defined as a global. With this change, amVim will jump to the type definition of the current identifier (even if it is in a different file). This does nothing in languages without type information, but if VS Code can figure out the type, it will take you to the definition. This is a different behavior to vim, but I think it is in the spirit of what gD is trying to help with.

The benefit is that you can now easily jump around the source without taking your hands off the keyboard, using gd and gD to take a look at where something is defined and what its type is, then Alt-Left to quickly take you back to where you were.

@jackfranklin
Copy link
Collaborator

@alisonatwork this looks great and two commands I'm definitely keen to add!

@aioutecism I think we could merge this?

Copy link
Owner

@aioutecism aioutecism left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@aioutecism
Copy link
Owner

Sorry guys. I found this PR breaks gg. Reverted and recreated the PR with details here: #257

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants